import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 导入Vant UI框架
import Vant, { Lazyload } from 'vant'
import 'vant/lib/index.css'
import store from './store'
import './styles/index.less'
import 'amfe-flexible'
// 全局使用处理时间模块
import '@/utils/formatdate'
Vue.use(Vant)
Vue.use(Lazyload, {
  lazyComponent: true
})
// 发生Loading chunk 0 failed.错误时的处理
router.onError((error) => {
  const pattern = /Loading chunk (\d)+ failed/g
  const isChunkLoadFailed = error.message.match(pattern)
  const targetPath = router.history.pending.fullPath
  if (isChunkLoadFailed) {
    router.replace(targetPath)
  }
})
// Vue.prototype.$Toast = Vant.Toast
Vue.config.productionTip = false
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
